import 'package:flutter_learn_vi/src/bean/bean_AppHomeEntity.dart';
import 'package:flutter_learn_vi/src/bean/bean_user.dart';
import 'package:flutter_learn_vi/src/common/user_helper.dart';
import 'package:flutter_learn_vi/src/net/dio_utils.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 3/29/21.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
///代码清单
class HomeModel {
  Future<List<BeanAppHomeEntity>> getHomeList({int isBanner = 0}) async {
    UserBean userBean = UserHelper.getInstance.userBean;
    Map<String, dynamic> monthMap = {
      "statues": 1,
      "isBanner": isBanner,
      "department": UserHelper.getInstance.userBean.department,
      "userType": userBean.userType,
    };

    ResponseInfo responseBannerInfo = await DioUtils.instance.getRequest(
      url: HttpHelper.appHomeList,
      queryParameters: monthMap,
    );
    List<BeanAppHomeEntity> homeList = [];
    if (responseBannerInfo.success) {
      List list = responseBannerInfo.data;
      list.forEach((element) {
        BeanAppHomeEntity newsBean = BeanAppHomeEntity.fromMap(element);
        homeList.add(newsBean);
      });
    }

    return homeList;
  }
}
